<template>
  <div class="app-container">
    <!-- 搜索区域 -->
    <el-form :inline="true" :model="queryParams">
      <el-form-item label="日志内容">
        <el-input v-model="query.logContent" placeholder="日志内容"></el-input>
      </el-form-item>
      <el-form-item label="IP">
        <el-input v-model="query.ip" placeholder="IP"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="search()">搜索</el-button>
        <el-button icon="el-icon-refresh">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 操作区域 -->
    <!-- <el-row :gutter="10">
      <el-col :span="1.5">
        <el-button
            type="primary"
            icon="el-icon-plus"
            @click="handleAdd"
        >新增</el-button>
      </el-col>
    </el-row> -->
    <!-- 表格区域 -->
    <el-table
      border
      :data="tableList">
      <el-table-column label="序号" type="index" align="center"></el-table-column>
      <el-table-column label="日志内容" prop="logContent" align="center"></el-table-column>
      <el-table-column label="IP" prop="ip" align="center"></el-table-column>
      <el-table-column label="请求方法" prop="method" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="请求参数" prop="requestParam" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="请求类型" prop="requestType" align="center"></el-table-column>
      <el-table-column label="请求地址" prop="requestUrl" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="耗时" prop="costTime" align="center"></el-table-column>
      <el-table-column label="操作时间" prop="createTime" align="center"></el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        @current-change="handleCurrentChange"
        :page-size="queryParams.pageSize"
        layout="total, prev, pager, next"
        :total="queryParams.total">
        </el-pagination>
    </div>
  </div>
</template>

<script>
import { log } from '../../api/log'
export default {
  name: 'log',
  data () {
    return {
      queryParams: {
        pageSize: 10,
        pageNum: 1,
      },
      tableList: [],
      query: {}
    }
  },
  created () {
    this.queryPage()
  },
  methods: {
    queryPage () {
      log.queryPage(this.queryParams).then(res => {
        this.tableList = res.list
        this.queryParams.pageSize = res.pageSize
        this.queryParams.total = res.total
      }) 
    },
    handleCurrentChange (val) {
      this.queryParams.pageNum = val
      this.queryPage()
    },
    search () {
      this.$message.success(JSON.stringify(this.queryParams))
    }
  }
}
</script>

<style>

</style>